﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace HackerRank.Puzzles
{
    public class MaximizeXoRSolver
    {
        public static int maxXor(int l, int r)
        {
            int result = 0;

            for (int i = l; i <= r; i++)
            {
                for (int j = i; j <= r; j++)
                {
                    int currMaxOrVal = i ^ j;
                    result = currMaxOrVal > result ? currMaxOrVal : result; 
                }
            }

            return result;
        }
    }
}
